package br.edu.unifei.cct720.trabalho07.gui.painel;

import java.awt.Color;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.border.TitledBorder;

import br.edu.unifei.cct720.trabalho07.model.ponto.PontoControle;

public class PainelPontoControle extends javax.swing.JPanel {
	
	private String title = "";
	
	public PainelPontoControle(String title) {
		this.title = title;
		this.initComponents();
	}
	
	public void initComponents() {
		
		java.awt.GridBagConstraints gridBagConstraints;
		
		txtPontosControle = new javax.swing.JTextArea();
		scrollPane = new javax.swing.JScrollPane(txtPontosControle);
		
		scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		
		// Definindo o content que sera utilizado na janela
		this.setLayout(new java.awt.GridBagLayout());
		
		scrollPane.setBorder(BorderFactory.createTitledBorder(null, title, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
		gridBagConstraints.weightx = 100.0;
		gridBagConstraints.weighty = 100.0;
		gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
		this.add(scrollPane, gridBagConstraints);
	}
	
	// Declaracao dos componentes da GUI
	private javax.swing.JTextArea txtPontosControle;
	private javax.swing.JScrollPane scrollPane;
	
	/**
	 * 
	 * @param pontosControle
	 */
	public void setValorPontosControle(List<PontoControle> pontosControle) {
		
		// Declaracao de variaveis locais
		String valorPontos = "";
		
		for(PontoControle ptControl : pontosControle) {
			valorPontos += ptControl.getReferencia() + "(" + ptControl.getX() + ","  + ptControl.getY() + ")";
			valorPontos += "\n";
		}
		
		this.txtPontosControle.setText(valorPontos);
	}

	// Metodos getters e setters
	public javax.swing.JTextArea getTxtPontosControle() {
		return txtPontosControle;
	}
}
